package com.wangyb.wework.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: wangyb
 * @Date: 2021/8/5 6:06 下午
 */
public enum EventTypeEnum {
	//通讯录相关回调
	EVENT_EMPLOYEE("change_contact"),
	//客户相关回调
	EVENT_CONTACT("change_external_contact"),
	//客户群相关回调
	EVENT_CHAT("change_external_chat"),
	//客户标签相关回调
	EVENT_TAG("change_external_tag")
	;
	private  String label;
	EventTypeEnum(String  label){
		this.label = label;
	}
	public String getLabel(){
		return this.label;
	}
	public static EventTypeEnum get(String label){
		Optional<EventTypeEnum> result = Arrays.stream(EventTypeEnum.values()).filter(e -> e.getLabel().equals(label)).findFirst();
		if (result.isPresent()){
			return result.get();
		}else{
			throw new IllegalArgumentException("wrong event type:"+label);
		}
	}

}
